package com.example.springboot01.controller;

import com.example.springboot01.entity.TUser;
import com.example.springboot01.service.TUserService;
import com.example.springboot01.util.Result;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * (TUser)表控制层
 *
 * @author makejava
 * @since 2022-12-22 18:56:31
 */
@RestController
@CrossOrigin
public class TUserController2 {
    /**
     * 服务对象
     */
    @Resource
    private TUserService tUserService;

    @GetMapping("query")
    public Result queryAll(){
        return new Result<>(tUserService.queryAll()) ;
    }

    @PostMapping("add")
    public Result addUser(TUser tUser){
        boolean b = tUserService.addUser(tUser);
        return new Result(b);
    }

    @GetMapping("findByPage")
    public Result findByPage(Integer start, Integer pageNum){
        List<TUser> byPage = tUserService.findByPage(2, 5);
        return new Result<>(byPage);
    }
}

